﻿using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations;

using Comswing.Business.Entities;

namespace Comswing.Data.Configuration
{
    internal class UserLogConfiguration : EntityTypeConfiguration<UserLog>
    {
        public UserLogConfiguration()
        {
            HasKey(e => e.Id);

            Property(e => e.Id)
                .IsRequired()
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .HasColumnName("Id");

            Property(e => e.LoginDate)
                .IsRequired()
                .HasColumnName("LoginDate");

            Property(e => e.LogoutDate)
                .HasColumnName("LogoutDate");

            Property(e => e.IPAddress)
                .IsUnicode(false)
                .HasMaxLength(40)
                .HasColumnName("IPAddress");

            HasRequired(e => e.User)
                .WithMany(r => r.UserLogs)
                .HasForeignKey(e => e.UserId);

            ToTable("UserLog", "dbo");
        }
    }
}
